package org.mcb.zebra.portal.page;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@SuppressWarnings("unchecked")
public class ZebPageManager implements PageManager {
	private Map<String, ZebPage> pages = new ConcurrentHashMap<String, ZebPage>();
	private String defaultPage;
	public String getDefaultPage() {
		return defaultPage;
	}
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.page.PageManager#containsPage(java.lang.String)
	 */
	public boolean containsPage(String pageName){
		return pages.containsKey(pageName);
	}
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.page.PageManager#addPage(java.lang.String, org.mcb.zebra.portal.page.Page)
	 */
	public Page addPage(String pageName,ZebPage page){
		return pages.put(pageName,page);
	}
	
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.page.PageManager#getAllPage()
	 */
	public Collection getAllPage(){
		return pages.values();
	}
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.page.PageManager#removePage(java.lang.String)
	 */
	public Page removePage(String pageName){
		return pages.remove(pageName);
	}
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.page.PageManager#removeAllPage()
	 */
	public void removeAllPage(){
		pages.clear();
	}
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.page.PageManager#getPage(java.lang.String)
	 */
	public Page getPage(String pageName){
		return pages.get(pageName);
	}
	@Override
	public void setDefaultPage(String pageName) {
		this.defaultPage = pageName;	
	}
}
